home *** CD-ROM | disk | FTP | other *** search
- /* DriverPCIBusUtilities.c */
- /*
- * DriverPCIBusUtilities.c
- * Copyright © 1994 Apple Computer Inc. All rights reserved.
- *
- * These low-level routines access the PCI bus registers.
- *
- * Read/Write IO Byte/Long Use the Expansion Manager interface.
- * Read/Write Byte/Long Use the preferred memory interface.
- */
- /* .___________________________________________________________________________________.
- | In a production environment, the Read/Write Byte/Word/Long routines will normally |
- | be implemented by inline code segments (or macros). They are routines here to |
- | centralize last-chance low-level debug logging. |
- | |
- | Also, note that this function synchronizes I/O after every write. This is |
- | inefficient, but useful for testing. |
- .___________________________________________________________________________________.
- */
- #include "NCRDriverPrivate.h"
- #define DUMP_ALL (0 && USE_LOG_LIBRARY)
- /*
- * We don't trace these
- */
-
- /*
- * Read/write using the device's LogicalAddress.
- */
- void
- WriteByte(
- unsigned short chipRegister,
- UInt8 value
- )
- {
- UInt8 *ptr;
-
- #if DUMP_ALL
- {
- Str255 work;
-
- PStrCopy(work, "\pWriteByte(");
- AppendHexLeadingZeros(work, (UInt32) GLOBAL.pciCardBaseAddress, 8);
- PStrCat(work, "\p + ");
- AppendHexLeadingZeros(work, chipRegister, 2);
- PStrCat(work, "\p, ");
- AppendHexLeadingZeros(work, value, 2);
- PStrCat(work, "\p");
- LogString(work);
- }
- #endif
- ptr = (UInt8 *) (((UInt8 *) GLOBAL.pciCardBaseAddress) + chipRegister);
- *ptr = value;
- SynchronizeIO();
- }
-
- void
- WriteLong(
- unsigned short chipRegister,
- long value
- )
- {
- UInt32 *ptr;
-
- #if DUMP_ALL
- {
- Str255 work;
-
- PStrCopy(work, "\pWriteLong(");
- AppendHexLeadingZeros(work, (UInt32) GLOBAL.pciCardBaseAddress, 8);
- PStrCat(work, "\p + ");
- AppendHexLeadingZeros(work, chipRegister, 2);
- PStrCat(work, "\p, ");
- AppendHexLeadingZeros(work, value, 8);
- PStrCat(work, "\p)");
- LogString(work);
- }
- #endif
- ptr = (UInt32 *) (((UInt8 *) GLOBAL.pciCardBaseAddress) + chipRegister);
- *ptr = EndianSwap32Bit(value);
- SynchronizeIO();
- }
-
- UInt8
- ReadByte(
- unsigned short chipRegister
- )
- {
- UInt8 *ptr;
-
- ptr = (UInt8 *) (((UInt8 *) GLOBAL.pciCardBaseAddress) + chipRegister);
- return (*ptr);
- }
-
- UInt32
- ReadLong(
- unsigned short chipRegister
- )
- {
- UInt32 *ptr;
-
- ptr = (UInt32 *) (((UInt8 *) GLOBAL.pciCardBaseAddress) + chipRegister);
- return (EndianSwap32Bit(*ptr));
- }
-